import store from '@/store/index'
export const phoneInfo = () => {
    const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
    // console.log(menuButtonInfo)
    const mobileInfo = uni.getSystemInfoSync();
    const statusBarHeight = mobileInfo.statusBarHeight
    const menuButtonMaginTopBottom =
        menuButtonInfo.top - mobileInfo.statusBarHeight;
    const menuButtonContainerHeight =
        menuButtonInfo.height + menuButtonMaginTopBottom * 2;
    store.commit('SET_PHONEINFO', {
        height: menuButtonContainerHeight,
        statusBarHeight
    })
}
export const throttle = (fn, wait) => {
    var prev = Date.now();
    return function() {
        var context = this;
        var args = arguments;
        var now = Date.now();
        if (now - prev > wait) {
            fn.apply(context, args)
            prev = Date.now()
        }
    }
}
export const debounce = (func, wait) => {
    let timeout;
    return function() {
        let context = this;
        let args = arguments;
        let later = () => {
            timeout = null;
            func.apply(context, args);
        };
        clearTimeout(timeout);
        timeout = setTimeout(later, wait);
    }
}